﻿using System.ComponentModel;
using System.Drawing;
using System.IO;

namespace EzDeploy.Core
{
    public class DeployGridItem
    {
        readonly AssemblyInfo _assemblyName;
        readonly string _itemName;
        readonly string _itemFullPath;
        readonly string _itemPath;
        readonly string _itemVersion;
        DeploymentType _deploymentType;
        readonly VersionStatus _itemStatus;
        readonly Image _itemStatusImage;

        [Browsable(false)]
        public AssemblyInfo AssemblyName
        {
            get
            {
                return _assemblyName;
            }
        }

        public string ItemName
        {
            get
            {
                return _itemName;
            }
        }

        public string ItemVersion
        {
            get
            {
                return _itemVersion;
            }
        }

        public string ItemFullPath
        {
            get
            {
                return _itemFullPath;
            }
        }

        public string ItemPath
        {
            get
            {
                return _itemPath;
            }
        }

        public DeploymentType DeploymentType
        {
            get
            {
                return _deploymentType;
            }
            set
            {
                _deploymentType = value;
            }
        }

        public Image ItemStatusImage
        {
            get
            {
                return _itemStatusImage;
            }
        }

        public VersionStatus ItemStatus
        {
            get
            {
                return _itemStatus;
            }
        }

        public DeployGridItem(AssemblyInfo deployItem)
        {
            _assemblyName = deployItem;
            _itemFullPath = deployItem.FullyQualifiedPath;
            _itemVersion = deployItem.Version;
            _itemName = deployItem.Name;

            _itemPath = Path.GetFileName( deployItem.FullyQualifiedPath);
            _itemStatus = deployItem.Status;
            _deploymentType = deployItem.Status != VersionStatus.Unknown ? DeploymentType.Include: Core.DeploymentType.Exclude;

            switch(deployItem.Status)
            {
                case VersionStatus.Match:
                    _itemStatusImage = EzDeploy.Properties.Resources.HotSpot_Black;
                    break;
                case VersionStatus.Unknown:
                    _itemStatusImage = EzDeploy.Properties.Resources.HotSpot_Color;
                    break;
                case VersionStatus.Mismatch:
                    _itemStatusImage = EzDeploy.Properties.Resources.HotSpot_With_Arrow;
                    break;
            }
        }
    }
}
